<template>
  <div id="setup-page" :style="{
    width:'100%',
    height: (this.getWinSize().height-84-this.getSafeArea().top)+'px',
    paddingTop:(this.getSafeArea().top+34)+'px'
  }">
    <div class="page-title" :style="{
      top:(this.getSafeArea().top)+'px'
    }">
      <div id="back-button" @click="$router.push('/MemberHome')">
        <i href="javascript:void(0)" class="el-icon-arrow-left"></i>
      </div>
      <span>设置</span>
    </div>
    <div class="form">
      <div class="item" @click="$router.push('/MemberInfo')">
        <div class="left">
          <i class="icon iconfont icon-gerenziliao"></i>
          <span>资料修改</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="$router.push('MemberChangePassword')">
        <div class="left">
          <i class="icon iconfont icon-genggaimima"></i>
          <span>密码修改</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>

      <div class="item" @click="$router.push('MemberChangeMobile')">
        <div class="left">
          <i class="icon iconfont icon-shoujibangding"></i>
          <span>手机号码修改</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>

<!--      <div class="item" @click="$router.push('MemberWechatBinding')">-->
<!--        <div class="left">-->
<!--          <i class="icon iconfont icon-bangdingweixin"></i>-->
<!--          <span>微信绑定</span>-->
<!--        </div>-->
<!--        <div class="right">-->
<!--          <i class="el-icon-arrow-right"></i>-->
<!--        </div>-->
<!--        <div class="c"></div>-->
<!--      </div>-->

      <div class="item"  v-if="getIsShifu()" @click="$router.push('MemberBindingShopList')">
        <div class="left">
          <i class="icon iconfont icon-dianpu"></i>
          <span>绑定店铺列表</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>

      <div class="item" @click="$router.push('/MemberAddressList')">
        <div class="left">
          <i class="icon iconfont icon-dizhi"></i>
          <span>地址管理</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>

      <div class="item" @click="accountCancel">
        <div class="left">
          <i class="icon iconfont icon-zhuxiao"></i>
          <span v-if="!userInfo.isCancel || userInfo.isCancel.id===0">账号注销</span>
          <span class="red" v-if="userInfo.isCancel.id===1" v-text="'申请注销时间: '+userInfo.cancelTime"></span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="myCheckAppVersion">
        <div class="left">
          <i class="icon iconfont icon-banben"></i>
          当前版本 (<span style="text-indent: 0px; font-size: 12px;" class="red" v-text="AppVersion"></span> )
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="myCheckAppVersion">
        <div class="left">
          <i class="icon iconfont icon-banben"></i>
          App备案号(<span style="text-indent: 0px; font-size: 12px;" class="red">京ICP备2011236402号-1A</span> )
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="$router.push('/UseHelp')">
        <div class="left">
          <i class="el-icon el-icon-question"></i>
          <span>使用帮助</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="c"></div>
    </div>


    <div class="page-bottom">
      <el-button type="danger" :loading="loading" :disabled="loading" size="medium" style="width: 90%" @click="loginOut">退出登录</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "Setup",
  data:function () {
    return {
      userInfo:{
        icon:'',
        nickname:'',
        isCancel:{
          id:0
        }
      },
      AppVersion:'V1.0.89',
      loading:false
    }
  },
  mounted() {
    if (localStorage.getItem('AppVersion')){
      this.appVersion=localStorage.getItem('AppVersion')
    }
    this.getDetail()
  },
  methods:{
    myCheckAppVersion:function () {
      this.bus.$emit('AppVersionCallBus')
    },
    accountCancel:function () {
      let $this=this
      if (!$this.CurrUser.IsLogin()){
        $this.$router.push('/Login')
        return
      }
      var msg='您是否确认申请注销?'
      var api='accountCancelSubmit'
      if ($this.userInfo.isCancel.id===0){
        msg='您是否确认申请注销(系统审核通过正式注销)?'
        api='accountCancelSubmit'
      }else{
        msg='您是否确认取消注销申请'
        api='accountCancelCancel'
      }
      $this.$confirm(msg, '系统提示', {
        customClass:'my-confirm-box',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        backType: 'warning'
      }).then(() => {
        let $this = this
        $this.MyRequest($this.ApiDoNameMember + 'Member/'+api, {}, function () {
          $this.getDetail()
          $this.$forceUpdate()
        }, function (msg) {
          $this.$message.error(msg)
        })
      }).catch(() => {

      });
    },
    getDetail:function () {
      let $this = this
      $this.MyRequest($this.ApiDoNameMember + 'Member/info', {}, function (data) {
          $this.userInfo.nickname = data.nickname
          $this.userInfo.icon = data.icon
          $this.userInfo.isCancel = data.isCancel
          $this.userInfo.cancelTime = data.cancelTime
          $this.$forceUpdate()
        }, function (msg) {
        $this.$message.error(msg)
        // $this.form.password = ''
      })
    },
    loginOut:function () {
      let $this=this
      this.$confirm('您确认要进行该操作吗, 是否继续?', '系统提示', {
        customClass:'my-confirm-box',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        backType: 'warning'
      }).then(() => {

        $this.MyRequest($this.ApiDoNameAuth + 'User/loginOut', {}, function (data) {
          $this.loading=false

          $this.$forceUpdate()
        }, function (msg) {
          $this.loading=false
          // $this.$message.error(msg)
        })
        setTimeout(function () {
          $this.CurrUser.setCache(null)
          localStorage.removeItem('currMemberId')
          window.location.href='/'
        },500)


      }).catch(() => {

      });
    },
  }
}
</script>

<style scoped>

</style>
